package com.ruoyi.system.service.impl;

import com.ruoyi.system.mapper.AgoniRewardMapper;
import com.ruoyi.system.pojo.dto.AddRewardPunishmentDTO;
import com.ruoyi.system.pojo.entity.Reward;
import com.ruoyi.system.service.IAgoniRewardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IAgoniRewardServiceImpl implements IAgoniRewardService {

    @Autowired
    private AgoniRewardMapper rewardMapper;

    /**
     * TODO: 奖惩表的获取
     */
    @Override
    public List<Reward> selectRewardList() {
        return rewardMapper.selectRewardList();
    }


    /**
     * TODO: 根据用户id获取奖惩信息
     */
    @Override
    public List<Reward> selectRewardListByUserId(Long userId) {
        return rewardMapper.selectRewardListByUserId(userId);
    }


    /**
     * TODO: 根据奖惩id获取奖惩信息
     */
    @Override
    public Reward selectRewardById(Long rewardId) {
        return rewardMapper.selectRewardById(rewardId);
    }


    // TODO: APP惩表的新增

    @Override
    public int insertReward(AddRewardPunishmentDTO addRewardPunishmentDTO, Long userId) {
        Reward reward = new Reward();
        reward.setUserId(Math.toIntExact(userId));
        reward.setType(addRewardPunishmentDTO.getType());
        reward.setGrade(addRewardPunishmentDTO.getGrade());
        reward.setItem(addRewardPunishmentDTO.getItem());
        reward.setDescription(addRewardPunishmentDTO.getDescription());
        rewardMapper.insertReward(reward);

        return 0;
    }


    // TODO: APP奖表的删除

    @Override
    public int deleteRewardById(Long id) {
        return rewardMapper.deleteRewardById(id);
    }
}


